# load packages
library(tidyverse)
library(ggplot2)
library(readxl)
library(dplyr)
library(scales)

#figure 1
figure1 <- read_excel('/Users/celinascott-buechler/DFP/dac_survey/Replication/Analysis/Focus Groups/focus-group-pre-post-surveys_all.xlsx')
#View(figure1)

figure1_3 <- figure1 %>% select(`3. If you marked “a lot”, “some”, or “only a little”  for question 2, would you overall approve or disapprove of a direct air capture project being built in or near your community?`)

colnames(figure1_3)[1] ="post_Q3"

figure1_3$post_Q3 <- factor(figure1_3$post_Q3, levels = c("N/A",
                                                          "Strongly disapprove",
                                                          "Somewhat disapprove",
                                                          "Neither approve nor disapprove",
                                                          "Somewhat approve",
                                                          "Strongly approve"))

tab <- as.data.frame(table(figure1_3))
tab$perc <- tab$Freq/sum(tab$Freq)


ggplot(tab, aes(x = post_Q3, y = perc)) +
  geom_bar(stat = "identity", width = 0.7, fill = "#021F82") +
  geom_text(aes(label = scales::percent(perc, accuracy = 1), fontface = "bold"),
            vjust = -0.75) +
  scale_y_continuous(labels = scales::percent) +
  theme_minimal() +
  theme(axis.title.y = element_blank(),
        panel.grid.minor = element_blank(),
        axis.title.x = element_blank())


figure1_8 <- figure1 %>% select(`8. After discussing direct air capture in your breakout group, how likely or unlikely are you to consider a direct air capture hub in your community if it follows your group’s project proposal?`)

colnames(figure1_8)[1] ="post_Q8"

figure1_8$post_Q8 <- factor(figure1_8$post_Q8, levels = c("Don't know",
                                                          "Very unlikely",
                                                          "Somewhat unlikely",
                                                          "Neither likely nor unlikely",
                                                          "Somewhat likely",
                                                          "Very likely"))

tab2 <- as.data.frame(table(figure1_8))
tab2$perc <- tab2$Freq/sum(tab2$Freq)

ggplot(tab2, aes(x = post_Q8, y = perc)) +
  geom_bar(stat = "identity", width = 0.7, fill = "#021F82") +
  geom_text(aes(label = scales::percent(perc, accuracy = 1), fontface = "bold"),
            vjust = -0.75) +
  scale_y_continuous(labels = scales::percent) +
  theme_minimal() +
  theme(axis.title.y = element_blank(),
        panel.grid.minor = element_blank(),
        axis.title.x = element_blank())



#Evaluating the focus froup pre- and post-survey responses
table(prepost$`7. After learning more about direct air capture at the beginning of the workshop, are you likely or unlikely to consider having a direct air capture hub in your community in general?`)

table(prepost$`8. After discussing direct air capture in your breakout group, how likely or unlikely are you to consider a direct air capture hub in your community if it follows your group’s project proposal?`)

ggplot(prepost)+geom_bar(aes(x=`7. After learning more about direct air capture at the beginning of the workshop, are you likely or unlikely to consider having a direct air capture hub in your community in general?`:`8. After discussing direct air capture in your breakout group, how likely or unlikely are you to consider a direct air capture hub in your community if it follows your group’s project proposal?`), stat='count')



